package Day08_11;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class Test_Map01 {
    public static void main(String[] args) {
        Map m1 = new HashMap();
        // put(key,value)
        m1.put(1,"a");
        m1.put(2,"b");
        m1.put(3,"c");
        m1.put(4,"d");

        System.out.println( m1.get(1) );//通过键值 k 来取 value
        System.out.println( m1.get(2) );
        System.out.println( m1.get(3) );
        System.out.println( m1.get(4) );

        System.out.println("清空前,m1集合大小:" + m1.size());
        // m1.clear();
        //System.out.println("清空后,m1集合大小:" + m1.size());

        boolean b1 = m1.containsKey( 10);
        System.out.println(b1);
        String a1 = new String("a");
        boolean b2 = m1.containsValue(a1);
        System.out.println(b2);

        m1.remove(0);
        m1.remove(0);
        m1.remove(0);
        m1.remove(0);
        System.out.println("Remove()后,m1集合大小:" + m1.size());
        Collection c1 = m1.keySet();
        Object[] o1 = c1.toArray();
        for(Object i : o1){
            System.out.println( i );
        }
      //  Collection c2 = m1.keySet();//获取 m1 中所有的键值。

    }
}
